package com.sprouting.personal.service;

import com.sprouting.personal.model.entity.HomeworkRecord;
import com.sprouting.personal.dao.HomeworkRecordDao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sprouting.personal.model.vo.HomeworkSubmitStatistics;
import com.sprouting.personal.model.vo.HomeworkVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 家庭作业记录 service接口实现
 *
 * @author ：sprouting
 * @date 创建时间： 2023-07-15 10:37:16
 */
@Service
@Slf4j
public class HomeworkRecordService extends ServiceImpl<HomeworkRecordDao, HomeworkRecord> {

	@Resource
	private HomeworkRecordDao homeworkRecordDao;

	/**
	 * 通过ID查询单条数据
	 * @param id 主键
	 * @return 家庭作业记录
	 */
	public HomeworkRecord getHomeworkRecordById(String id) {
		return homeworkRecordDao.getHomeworkRecordById(id);
	}

	/**
	 * 分页查询
	 * @param page 分页参数
	 * @param homeworkRecord 查询参数
	 * @return 条件查询结果
	 */
	public Page<HomeworkRecord> getHomeworkRecordPage(Page page, HomeworkRecord homeworkRecord){
		return homeworkRecordDao.getHomeworkRecordPage(page, homeworkRecord);
	}

	/**
	 * 获取作业提交统计,按年
	 * 这里获取最近5年的作业提交情况
	 * @param memberFamilyId 家庭成员ID
	 * @return
	 */
	public List<HomeworkSubmitStatistics> getHomeworkSubmitStatisticsYear(String memberFamilyId) {
		return homeworkRecordDao.getHomeworkSubmitStatisticsYear(memberFamilyId);
	}

	/**
	 * 获取作业提交统计,按月
	 * 这里获取最近5个月的作业提交情况
	 * @param memberFamilyId 家庭成员ID
	 * @return
	 */
	public List<HomeworkSubmitStatistics> getHomeworkSubmitStatisticsMonth(String memberFamilyId) {
		return homeworkRecordDao.getHomeworkSubmitStatisticsMonth(memberFamilyId);
	}

	/**
	 * 获取过去5天的作业提交数量
	 * @param memberFamilyId 家庭成员ID
	 * @return
	 */
	public List<HomeworkSubmitStatistics> getHomeworkSubmitStatisticsDay(String memberFamilyId) {
		return homeworkRecordDao.getHomeworkSubmitStatisticsDay(memberFamilyId);
	}

	/**
	 * 获取今天已完成的(不含周期性的)
	 * @param memberFamilyId 家庭成员ID
	 * @return
	 */
	public List<HomeworkVo> getHomeworkRecordByCreateTime(String memberFamilyId) {
		return homeworkRecordDao.getHomeworkRecordByCreateTime(memberFamilyId);
	}
}
